const information = document.getElementById('info')
information.innerText = `本应用正在使用 Chrome (v${versions.chrome()}), Node.js (v${versions.node()}), 和 Electron (v${versions.electron()})`


const func = async () => {
  const pong = document.querySelector("#pong")
  const response = await versions.ping()
  console.log("打印pong", response)
  pong.innerText = response
}

func();


const msg = document.querySelector("#msg");

msg.addEventListener('click', async () => {
  const obj = await versions.sedMsg()
  msg.innerText = JSON.stringify(obj)
})


const channelOne = document.querySelector("#channelOne");
const channelTwo = document.querySelector("#channelTwo");

channelOne.addEventListener('click' , async () => {
  const data = await versions.getProtOne();
  console.log("channelOne", data)
})


const getFile = document.querySelector("#getFile");
getFile.addEventListener('click' , async () => {
  const data = await versions.openFile();
  console.log("打开的文件内容为", data)
})



const send = document.querySelector("#send");
send.addEventListener('click' , async (e) => {
  e.preventDefault()
  versions.showContextMenu()
})


const getChannel = document.querySelector("#getChannel");
getChannel.addEventListener('click' , async (e) => {
  e.preventDefault();
  versions.getChannel();
})

// 开始下
const download = document.querySelector("#download");
download.addEventListener('click' , async (e) => {
  e.preventDefault();
  versions.download();
})

// 暂停
const pause = document.querySelector("#pause");
pause.addEventListener('click' , async (e) => {
  e.preventDefault();
  versions.pause();
})


// 继续下载
const unpause = document.querySelector("#unpause");
unpause.addEventListener('click' , async (e) => {
  e.preventDefault();
  versions.unpause();
})
